library(ggplot2)

topic_props <- data.frame(Major = c("Bio.", "Bio.", "Bio.",
                                    "Eng.", "Eng.","Eng.",
                                    "Random", "Random", "Random"),
                          Topics = c(14/102, 13/102, 75/102, 
                                     20/107, 20/107,67/107,
                                     0,0,1),
                          Gender = c("F", "M", "Non-significant",
                                     "F", "M", "Non-significant",
                                     "F", "M", "Non-significant"))
topic_props <- topic_props[rev(order(topic_props$Gender)),]

topic_props$Gender <- factor(topic_props$Gender, levels = c("Non-significant",
                                                            "M",
                                                            "F"))

topic_props$Major <- factor(topic_props$Major, levels = c("Random",
                                                          "Bio.",
                                                          "Eng."))

pdf("topic_proportions_fig.pdf", width = 10, height = 6)
ggplot(topic_props, aes(x = Major, y = Topics, 
                        fill =Gender)) +
  geom_bar(stat = "identity", width = .65) +
  scale_fill_manual(values =c('F' = "#F8766D", 'M' = "#00BFC4", 
                              'Non-significant' = "grey89")) +
  scale_y_continuous(labels = scales::label_percent(accuracy = 1L),
                     breaks = seq(0,1,.1)) +
  ylab("Proportion of Topics") +
  xlab("\nSTM Model") +
  labs(title = "Intended Major Specific Models and Random Binary Variable Model") +
  theme_light()
dev.off()
  